<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Skilful: Исходный файл Skilful/QuikControl.cs</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Создано системой Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Поиск');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Титульная&nbsp;страница</span></a></li>
      <li><a href="namespaces.html"><span>Пакеты</span></a></li>
      <li><a href="annotated.html"><span>Классы</span></a></li>
      <li class="current"><a href="files.html"><span>Файлы</span></a></li>
      <li><a href="dirs.html"><span>Алфавитный&nbsp;указатель&nbsp;директорий</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Поиск" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Файлы</span></a></li>
    </ul>
  </div>
  <div class="navpath">
    <ul>
      <li><a class="el" href="dir_7adcdc1edff7620168fbc20357cad448.html">Skilful</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<h1>QuikControl.cs</h1>  </div>
</div>
<div class="contents">
<a href="_quik_control_8cs.html">См. документацию.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ﻿<span class="comment">//---------------------------------------------------------------------------------------------------------------</span>
<a name="l00002"></a>00002 <span class="comment">// Skilful. Tactica Adversa graphic and analysis tool.</span>
<a name="l00003"></a>00003 <span class="comment">// Copyright (C) 2010 &quot;...&quot;, Pavel Kadomin (S_PASHKA)</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">// This program is free software; you can redistribute it and/or</span>
<a name="l00006"></a>00006 <span class="comment">// modify it under the terms of the GNU General Public License</span>
<a name="l00007"></a>00007 <span class="comment">// as published by the Free Software Foundation; either version 2</span>
<a name="l00008"></a>00008 <span class="comment">// of the License, or (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// This program is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00013"></a>00013 <span class="comment">// GNU General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// You should have received a copy of the GNU General Public License</span>
<a name="l00016"></a>00016 <span class="comment">// along with this program; if not, write to the Free Software</span>
<a name="l00017"></a>00017 <span class="comment">// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.</span>
<a name="l00018"></a>00018 <span class="comment">//</span>
<a name="l00019"></a>00019 <span class="comment">// mail: support@protoforma.com </span>
<a name="l00020"></a>00020 <span class="comment">//---------------------------------------------------------------------------------------------------------------</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="keyword">using</span> System;
<a name="l00023"></a>00023 <span class="keyword">using</span> System.Collections.Generic;
<a name="l00024"></a>00024 <span class="keyword">using</span> System.ComponentModel;
<a name="l00025"></a>00025 <span class="keyword">using</span> System.Data;
<a name="l00026"></a>00026 <span class="keyword">using</span> System.Drawing;
<a name="l00027"></a>00027 <span class="keyword">using</span> System.Linq;
<a name="l00028"></a>00028 <span class="keyword">using</span> System.Text;
<a name="l00029"></a>00029 <span class="keyword">using</span> System.Windows.Forms;
<a name="l00030"></a>00030 <span class="keyword">using</span> System.IO;
<a name="l00031"></a>00031 <span class="keyword">using</span> System.Threading;
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="keyword">namespace </span>Skilful
<a name="l00034"></a>00034 {
<a name="l00035"></a>00035         
<a name="l00036"></a><a class="code" href="class_skilful_1_1_quik_control.html">00036</a>     <span class="keyword">public</span> <span class="keyword">partial class </span><a class="code" href="class_skilful_1_1_quik_control.html">QuikControl</a> : Form
<a name="l00037"></a>00037     {
<a name="l00038"></a>00038         <span class="keywordtype">string</span> LoadHistoryDir;
<a name="l00039"></a>00039         <span class="keywordtype">string</span> LoadQuotesDir;
<a name="l00040"></a>00040 
<a name="l00041"></a><a class="code" href="class_skilful_1_1_quik_control.html#ad8b566c7ce953c1c2b1ff8afc0ddaa5c">00041</a>         <span class="keyword">public</span> <a class="code" href="class_skilful_1_1_quik_control.html#ad8b566c7ce953c1c2b1ff8afc0ddaa5c">QuikControl</a>()
<a name="l00042"></a>00042         {
<a name="l00043"></a>00043             InitializeComponent();
<a name="l00044"></a>00044         }
<a name="l00045"></a>00045 
<a name="l00046"></a>00046         <span class="keyword">private</span> <span class="keywordtype">void</span> button1_Click(<span class="keywordtype">object</span> sender, EventArgs e)
<a name="l00047"></a>00047         {
<a name="l00048"></a>00048             this.Close();
<a name="l00049"></a>00049         }
<a name="l00050"></a>00050 
<a name="l00051"></a>00051         <span class="comment">//changing the quotes directory</span>
<a name="l00052"></a>00052         <span class="keyword">private</span> <span class="keywordtype">void</span> linkLabel1_LinkClicked(<span class="keywordtype">object</span> sender, LinkLabelLinkClickedEventArgs e)
<a name="l00053"></a>00053         {
<a name="l00054"></a>00054             <span class="keywordflow">if</span> (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
<a name="l00055"></a>00055             {
<a name="l00056"></a>00056                 <span class="keywordtype">string</span> LoadQuotesDir = folderBrowserDialog1.SelectedPath;
<a name="l00057"></a>00057                 linkLabel1.Text = LoadQuotesDir;
<a name="l00058"></a>00058                 XMLConfig.Set(<span class="stringliteral">&quot;QuikQuotesDir&quot;</span>, LoadQuotesDir);
<a name="l00059"></a>00059                 <span class="comment">//Properties.Settings.Default.Save();</span>
<a name="l00060"></a>00060                 <a class="code" href="class_skilful_1_1_quik_control.html#ab201bb9ed667b146997836f3d2ae264b">LoadQuotesFilesList</a>(LoadQuotesDir);
<a name="l00061"></a>00061                 fileSystemWatcher1.Path = LoadQuotesDir;
<a name="l00062"></a>00062             }
<a name="l00063"></a>00063         }
<a name="l00064"></a>00064 
<a name="l00065"></a>00065         <span class="keyword">private</span> <span class="keywordtype">void</span> QuikControl_Shown(<span class="keywordtype">object</span> sender, EventArgs e)
<a name="l00066"></a>00066          {  
<a name="l00067"></a>00067             LoadQuotesDir = XMLConfig.Get(<span class="stringliteral">&quot;QuikQuotesDir&quot;</span>);
<a name="l00068"></a>00068             LoadHistoryDir = XMLConfig.Get(<span class="stringliteral">&quot;QuikHistoryDir&quot;</span>);
<a name="l00069"></a>00069             linkLabel1.Text = LoadQuotesDir;
<a name="l00070"></a>00070             linkLabel2.Text = LoadHistoryDir;                
<a name="l00071"></a>00071          }
<a name="l00072"></a>00072 
<a name="l00073"></a>00073         <span class="comment">//loading the list of available quotes</span>
<a name="l00074"></a><a class="code" href="class_skilful_1_1_quik_control.html#ab201bb9ed667b146997836f3d2ae264b">00074</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_skilful_1_1_quik_control.html#ab201bb9ed667b146997836f3d2ae264b">LoadQuotesFilesList</a>(<span class="keywordtype">string</span> dir)
<a name="l00075"></a>00075          {
<a name="l00076"></a>00076              <span class="keywordtype">int</span> foundTF = 0;
<a name="l00077"></a>00077              <span class="keywordtype">int</span> foundTicker = 0;
<a name="l00078"></a>00078              String line;
<a name="l00079"></a>00079              String lineTF;
<a name="l00080"></a>00080              String lineTicker;
<a name="l00081"></a>00081                 DirectoryInfo di = <span class="keyword">new</span> DirectoryInfo(dir);
<a name="l00082"></a>00082                 FileInfo[] fi = di.GetFiles();
<a name="l00083"></a>00083                 listBox2.Items.Clear();
<a name="l00084"></a>00084                 listBox1.Items.Clear();
<a name="l00085"></a>00085                 listBox3.Items.Clear();
<a name="l00086"></a>00086                 <span class="keywordflow">foreach</span> (FileInfo fiTemp <span class="keywordflow">in</span> fi)
<a name="l00087"></a>00087                 {
<a name="l00088"></a>00088                     <span class="keyword">using</span> (StreamReader sr = <span class="keyword">new</span> StreamReader(dir +<span class="stringliteral">&quot;\\&quot;</span>+ fiTemp.Name))
<a name="l00089"></a>00089                     {
<a name="l00090"></a>00090                       <span class="keywordflow">if</span> ((line = sr.ReadLine()) != null)
<a name="l00091"></a>00091                         {
<a name="l00092"></a>00092                             foundTF = line.IndexOf(<span class="stringliteral">&quot;,&quot;</span>);
<a name="l00093"></a>00093                             <span class="keywordflow">if</span> (foundTF!=-1)
<a name="l00094"></a>00094                             {
<a name="l00095"></a>00095                             lineTF = line.Substring(foundTF+1,1);
<a name="l00096"></a>00096                             <span class="keywordflow">if</span> (lineTF == <span class="stringliteral">&quot;5&quot;</span>) <span class="comment">//check the base timeframe</span>
<a name="l00097"></a>00097                             {
<a name="l00098"></a>00098                                 foundTicker = line.IndexOf(<span class="stringliteral">&quot; &quot;</span>);
<a name="l00099"></a>00099                                 lineTicker = line.Substring(0, foundTicker); <span class="comment">//get the ticker</span>
<a name="l00100"></a>00100                                 listBox2.Items.Add(fiTemp.Name);
<a name="l00101"></a>00101                                 listBox1.Items.Add(lineTicker);
<a name="l00102"></a>00102                                 listBox3.Items.Add(<span class="stringliteral">&quot;&lt;file not found&gt;&quot;</span>);
<a name="l00103"></a>00103                             }
<a name="l00104"></a>00104                             }
<a name="l00105"></a>00105                         }
<a name="l00106"></a>00106                       sr.Close();
<a name="l00107"></a>00107                     }
<a name="l00108"></a>00108                 }
<a name="l00109"></a>00109             }
<a name="l00110"></a>00110 
<a name="l00111"></a>00111       
<a name="l00112"></a>00112 
<a name="l00113"></a>00113          <span class="keyword">private</span> <span class="keywordtype">void</span> listBox1_Click(<span class="keywordtype">object</span> sender, EventArgs e)
<a name="l00114"></a>00114          {
<a name="l00115"></a>00115              listBox2.SelectedIndex = listBox1.SelectedIndex;
<a name="l00116"></a>00116              listBox3.SelectedIndex = listBox1.SelectedIndex;
<a name="l00117"></a>00117 
<a name="l00118"></a>00118          }
<a name="l00119"></a>00119 
<a name="l00120"></a>00120          <span class="keyword">private</span> <span class="keywordtype">void</span> listBox2_SelectedIndexChanged(<span class="keywordtype">object</span> sender, EventArgs e)
<a name="l00121"></a>00121          {
<a name="l00122"></a>00122              listBox1.SelectedIndex = listBox2.SelectedIndex;
<a name="l00123"></a>00123              listBox3.SelectedIndex = listBox2.SelectedIndex;
<a name="l00124"></a>00124          }
<a name="l00125"></a>00125 
<a name="l00126"></a>00126          <span class="keyword">private</span> <span class="keywordtype">void</span> listBox3_SelectedIndexChanged(<span class="keywordtype">object</span> sender, EventArgs e)
<a name="l00127"></a>00127          {
<a name="l00128"></a>00128              listBox2.SelectedIndex = listBox3.SelectedIndex;
<a name="l00129"></a>00129              listBox1.SelectedIndex = listBox3.SelectedIndex;
<a name="l00130"></a>00130 
<a name="l00131"></a>00131          }
<a name="l00132"></a>00132 
<a name="l00133"></a>00133         <span class="comment">//change the history directory</span>
<a name="l00134"></a>00134          <span class="keyword">private</span> <span class="keywordtype">void</span> linkLabel2_LinkClicked(<span class="keywordtype">object</span> sender, LinkLabelLinkClickedEventArgs e)
<a name="l00135"></a>00135          {
<a name="l00136"></a>00136              <span class="keywordflow">if</span> (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
<a name="l00137"></a>00137              {
<a name="l00138"></a>00138                  <span class="keywordtype">string</span> LoadHistoryDir = folderBrowserDialog1.SelectedPath;
<a name="l00139"></a>00139                  linkLabel2.Text = LoadHistoryDir;
<a name="l00140"></a>00140                  XMLConfig.Set(<span class="stringliteral">&quot;.QuikHistoryDir&quot;</span>, LoadHistoryDir);
<a name="l00141"></a>00141                  <span class="comment">//Properties.Settings.Default.Save();</span>
<a name="l00142"></a>00142                  listBox3.Items.Clear();
<a name="l00143"></a>00143                  <a class="code" href="class_skilful_1_1_quik_control.html#a65adf2ecaa76d942376432e8b3aa25b7">LoadHistoryFilesList</a>(LoadHistoryDir);
<a name="l00144"></a>00144              }
<a name="l00145"></a>00145          }
<a name="l00146"></a>00146 
<a name="l00147"></a>00147          <span class="comment">//loading the list of available history files</span>
<a name="l00148"></a><a class="code" href="class_skilful_1_1_quik_control.html#a65adf2ecaa76d942376432e8b3aa25b7">00148</a>          <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_skilful_1_1_quik_control.html#a65adf2ecaa76d942376432e8b3aa25b7">LoadHistoryFilesList</a>(<span class="keywordtype">string</span> Histdir)
<a name="l00149"></a>00149          {
<a name="l00151"></a>00151              <span class="keywordtype">int</span> i =0;
<a name="l00154"></a>00154              DirectoryInfo Histdi = <span class="keyword">new</span> DirectoryInfo(Histdir);
<a name="l00155"></a>00155              FileInfo[] Histfi = Histdi.GetFiles();
<a name="l00156"></a>00156              <span class="keywordflow">foreach</span> (FileInfo HistfiTemp <span class="keywordflow">in</span> Histfi)
<a name="l00157"></a>00157              {
<a name="l00158"></a>00158                  <span class="keywordflow">for</span> (i = 0; i &lt; listBox2.Items.Count; i++)
<a name="l00159"></a>00159                  {
<a name="l00160"></a>00160                      <span class="comment">//the quotes and history files assigns by the filename, that must be equal to the ticker name</span>
<a name="l00161"></a>00161                      <span class="keywordflow">if</span> (listBox2.Items[i].ToString().ToLower() == HistfiTemp.Name.ToLower())
<a name="l00162"></a>00162                      {
<a name="l00163"></a>00163                          listBox3.Items[i] = HistfiTemp.Name;
<a name="l00164"></a>00164                      }                     
<a name="l00165"></a>00165                  }           
<a name="l00166"></a>00166              }
<a name="l00167"></a>00167             
<a name="l00168"></a>00168          }
<a name="l00169"></a>00169 
<a name="l00170"></a>00170          <span class="keyword">private</span> <span class="keywordtype">void</span> fileSystemWatcher1_Changed_1(<span class="keywordtype">object</span> sender, FileSystemEventArgs e)
<a name="l00171"></a>00171          {
<a name="l00172"></a>00172              <span class="comment">//in case of changes update the history file</span>
<a name="l00173"></a>00173              <span class="keywordflow">if</span> (CompareQuotes(e.FullPath) == <span class="keyword">true</span>) 
<a name="l00174"></a>00174              {
<a name="l00175"></a>00175                  <span class="comment">//Console.WriteLine(&quot;True&quot;);</span>
<a name="l00176"></a>00176                  <span class="keywordflow">if</span> (File.Exists(LoadHistoryDir + <span class="stringliteral">&quot;\\&quot;</span> + Path.GetFileName(e.FullPath))) UpdateHistoryQuotes(e.FullPath);
<a name="l00177"></a>00177              }
<a name="l00178"></a>00178          }
<a name="l00179"></a>00179 
<a name="l00180"></a>00180          <span class="comment">//check for the quotes changes</span>
<a name="l00181"></a>00181          <span class="keyword">private</span> <span class="keywordtype">bool</span> CompareQuotes(<span class="keywordtype">string</span> FileName)
<a name="l00182"></a>00182          {
<a name="l00183"></a>00183             String QuotesLine = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00184"></a>00184             String HistoryLine = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00185"></a>00185             <span class="keywordtype">int</span> i;
<a name="l00186"></a>00186            
<a name="l00187"></a>00187             <span class="keywordflow">for</span> (i = 0; i &lt; 15; i++)
<a name="l00188"></a>00188             {
<a name="l00189"></a>00189                 <span class="keywordflow">try</span>
<a name="l00190"></a>00190                 {
<a name="l00191"></a>00191                     <span class="comment">//get the last (up to date) quotes line from the history file</span>
<a name="l00192"></a>00192                     StreamReader HistoryFile = <span class="keyword">new</span> StreamReader(LoadHistoryDir + <span class="stringliteral">&quot;\\&quot;</span> + Path.GetFileName(FileName));
<a name="l00193"></a>00193                     <span class="keywordflow">while</span> (HistoryFile.EndOfStream != <span class="keyword">true</span>) HistoryLine = HistoryFile.ReadLine();
<a name="l00194"></a>00194 
<a name="l00195"></a>00195                     <span class="comment">//get the first (up to date) quotes line from the quotes file</span>
<a name="l00196"></a>00196                     StreamReader QuotesFile = <span class="keyword">new</span> StreamReader(FileName);
<a name="l00197"></a>00197                     QuotesLine = QuotesFile.ReadLine();
<a name="l00198"></a>00198                     HistoryFile.Close();
<a name="l00199"></a>00199                     QuotesFile.Close();
<a name="l00200"></a>00200                     <span class="keywordflow">break</span>;
<a name="l00201"></a>00201                 }
<a name="l00202"></a>00202                 <span class="keywordflow">catch</span>
<a name="l00203"></a>00203                 { Thread.Sleep(200); }
<a name="l00204"></a>00204             }
<a name="l00205"></a>00205 
<a name="l00206"></a>00206             <span class="comment">//get the content of the last quote in the history file</span>
<a name="l00207"></a>00207             <span class="keywordtype">string</span>[] HistQuotes = HistoryLine.Split(<span class="charliteral">&#39;,&#39;</span>);
<a name="l00208"></a>00208             <span class="keywordtype">int</span> HistDate = <span class="keywordtype">int</span>.Parse(HistQuotes[2]);
<a name="l00209"></a>00209             <span class="keywordtype">int</span> HistTime = <span class="keywordtype">int</span>.Parse(HistQuotes[3]);
<a name="l00210"></a>00210             <span class="keywordtype">double</span> HistHigh = <span class="keywordtype">double</span>.Parse(HistQuotes[5].Replace(<span class="charliteral">&#39;.&#39;</span>,<span class="charliteral">&#39;,&#39;</span>));;
<a name="l00211"></a>00211             <span class="keywordtype">double</span> HistLow = <span class="keywordtype">double</span>.Parse(HistQuotes[6].Replace(<span class="charliteral">&#39;.&#39;</span>,<span class="charliteral">&#39;,&#39;</span>));
<a name="l00212"></a>00212             <span class="keywordtype">double</span> HistClose = <span class="keywordtype">double</span>.Parse(HistQuotes[7].Replace(<span class="charliteral">&#39;.&#39;</span>,<span class="charliteral">&#39;,&#39;</span>));
<a name="l00213"></a>00213 
<a name="l00214"></a>00214             <span class="comment">//get the content of last quote in the quotes file</span>
<a name="l00215"></a>00215             <span class="keywordtype">string</span>[] QuotesQuotes = QuotesLine.Split(<span class="charliteral">&#39;,&#39;</span>);
<a name="l00216"></a>00216             <span class="keywordtype">int</span> QuotesDate = <span class="keywordtype">int</span>.Parse(QuotesQuotes[2]);
<a name="l00217"></a>00217             <span class="keywordtype">int</span> QuotesTime = <span class="keywordtype">int</span>.Parse(QuotesQuotes[3]);
<a name="l00218"></a>00218             <span class="keywordtype">double</span> QuotesHigh = <span class="keywordtype">double</span>.Parse(QuotesQuotes[5].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00219"></a>00219             <span class="keywordtype">double</span> QuotesLow = <span class="keywordtype">double</span>.Parse(QuotesQuotes[6].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00220"></a>00220             <span class="keywordtype">double</span> QuotesClose = <span class="keywordtype">double</span>.Parse(QuotesQuotes[7].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00221"></a>00221             
<a name="l00222"></a>00222             <span class="comment">//check the changes in the quotes (date, time, high, low, close)</span>
<a name="l00223"></a>00223             <span class="keywordflow">if</span> ((QuotesDate &gt; HistDate) || (QuotesTime &gt; HistTime) || (QuotesClose != HistClose) || (QuotesHigh != HistHigh) || (QuotesLow != HistLow)) 
<a name="l00224"></a>00224             {
<a name="l00225"></a>00225                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00226"></a>00226             }
<a name="l00227"></a>00227             <span class="keywordflow">else</span> 
<a name="l00228"></a>00228             {
<a name="l00229"></a>00229                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00230"></a>00230             }
<a name="l00231"></a>00231 
<a name="l00232"></a>00232                    
<a name="l00233"></a>00233          }
<a name="l00234"></a>00234 
<a name="l00235"></a>00235          <span class="keyword">private</span> <span class="keywordtype">void</span> UpdateHistoryQuotes(<span class="keywordtype">string</span> FileName)
<a name="l00236"></a>00236          {
<a name="l00237"></a>00237             String QuotesLine = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00238"></a>00238             String HistoryLine = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00239"></a>00239             String QuotesPrevLine = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00240"></a>00240             String HistoryPrevLine = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00241"></a>00241             <span class="keywordtype">int</span> i;
<a name="l00242"></a>00242             <span class="keywordtype">int</span> z=0;
<a name="l00243"></a>00243                     
<a name="l00244"></a>00244             <span class="keywordflow">for</span> (i = 0; i &lt; 15; i++)
<a name="l00245"></a>00245             {
<a name="l00246"></a>00246                 <span class="keywordflow">try</span>
<a name="l00247"></a>00247                 {
<a name="l00248"></a>00248                     <span class="comment">//get the last quote from history file</span>
<a name="l00249"></a>00249                     StreamReader HistoryFile = <span class="keyword">new</span> StreamReader(LoadHistoryDir + <span class="stringliteral">&quot;\\&quot;</span> + Path.GetFileName(FileName));
<a name="l00250"></a>00250                     <span class="keywordflow">while</span> (HistoryFile.EndOfStream != <span class="keyword">true</span>)
<a name="l00251"></a>00251                     {
<a name="l00252"></a>00252                         HistoryLine = HistoryFile.ReadLine();
<a name="l00253"></a>00253                         z++;
<a name="l00254"></a>00254                     }
<a name="l00255"></a>00255 
<a name="l00256"></a>00256                     <span class="comment">//get the previous quote from history file</span>
<a name="l00257"></a>00257                     StreamReader HistoryPrevFile = <span class="keyword">new</span> StreamReader(LoadHistoryDir + <span class="stringliteral">&quot;\\&quot;</span> + Path.GetFileName(FileName));
<a name="l00258"></a>00258                     z = z - 1;
<a name="l00259"></a>00259                     <span class="keywordflow">for</span> (i = 0; i &lt; z; i++)
<a name="l00260"></a>00260                     {
<a name="l00261"></a>00261                         HistoryPrevLine = HistoryPrevFile.ReadLine();
<a name="l00262"></a>00262                     }
<a name="l00263"></a>00263 
<a name="l00264"></a>00264                     <span class="comment">//get the last and previous quotes from the quotes file</span>
<a name="l00265"></a>00265                     StreamReader QuotesFile = <span class="keyword">new</span> StreamReader(FileName);
<a name="l00266"></a>00266                     QuotesLine = QuotesFile.ReadLine();
<a name="l00267"></a>00267                     QuotesPrevLine = QuotesFile.ReadLine();
<a name="l00268"></a>00268 
<a name="l00269"></a>00269                     HistoryFile.Close();
<a name="l00270"></a>00270                     HistoryPrevFile.Close();
<a name="l00271"></a>00271                     QuotesFile.Close();
<a name="l00272"></a>00272                     <span class="keywordflow">break</span>;
<a name="l00273"></a>00273                 }
<a name="l00274"></a>00274                 <span class="keywordflow">catch</span>
<a name="l00275"></a>00275                 { Thread.Sleep(200); } <span class="comment">//hush!!!</span>
<a name="l00276"></a>00276             }
<a name="l00277"></a>00277              
<a name="l00278"></a>00278              <span class="keywordtype">string</span>[] HistQuotes = HistoryLine.Split(<span class="charliteral">&#39;,&#39;</span>);
<a name="l00279"></a>00279              <span class="keywordtype">int</span> HistDate = <span class="keywordtype">int</span>.Parse(HistQuotes[2]);
<a name="l00280"></a>00280              <span class="keywordtype">int</span> HistTime = <span class="keywordtype">int</span>.Parse(HistQuotes[3]);
<a name="l00281"></a>00281              <span class="keywordtype">double</span> HistHigh = <span class="keywordtype">double</span>.Parse(HistQuotes[5].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>)); ;
<a name="l00282"></a>00282              <span class="keywordtype">double</span> HistLow = <span class="keywordtype">double</span>.Parse(HistQuotes[6].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00283"></a>00283              <span class="keywordtype">double</span> HistClose = <span class="keywordtype">double</span>.Parse(HistQuotes[7].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00284"></a>00284 
<a name="l00285"></a>00285              <span class="keywordtype">string</span>[] HistPrevQuotes = HistoryPrevLine.Split(<span class="charliteral">&#39;,&#39;</span>);
<a name="l00286"></a>00286              <span class="keywordtype">int</span> HistPrevDate = <span class="keywordtype">int</span>.Parse(HistPrevQuotes[2]);
<a name="l00287"></a>00287              <span class="keywordtype">int</span> HistPrevTime = <span class="keywordtype">int</span>.Parse(HistPrevQuotes[3]);
<a name="l00288"></a>00288              <span class="keywordtype">double</span> HistPrevHigh = <span class="keywordtype">double</span>.Parse(HistPrevQuotes[5].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>)); ;
<a name="l00289"></a>00289              <span class="keywordtype">double</span> HistPrevLow = <span class="keywordtype">double</span>.Parse(HistPrevQuotes[6].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00290"></a>00290              <span class="keywordtype">double</span> HistPrevClose = <span class="keywordtype">double</span>.Parse(HistPrevQuotes[7].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00291"></a>00291              
<a name="l00292"></a>00292              <span class="keywordtype">string</span>[] QuotesQuotes = QuotesLine.Split(<span class="charliteral">&#39;,&#39;</span>);
<a name="l00293"></a>00293              <span class="keywordtype">int</span> QuotesDate = <span class="keywordtype">int</span>.Parse(QuotesQuotes[2]);
<a name="l00294"></a>00294              <span class="keywordtype">int</span> QuotesTime = <span class="keywordtype">int</span>.Parse(QuotesQuotes[3]);
<a name="l00295"></a>00295              <span class="keywordtype">double</span> QuotesHigh = <span class="keywordtype">double</span>.Parse(QuotesQuotes[5].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00296"></a>00296              <span class="keywordtype">double</span> QuotesLow = <span class="keywordtype">double</span>.Parse(QuotesQuotes[6].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00297"></a>00297              <span class="keywordtype">double</span> QuotesClose = <span class="keywordtype">double</span>.Parse(QuotesQuotes[7].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00298"></a>00298 
<a name="l00299"></a>00299              <span class="keywordtype">string</span>[] QuotesPrevQuotes = QuotesPrevLine.Split(<span class="charliteral">&#39;,&#39;</span>);
<a name="l00300"></a>00300              <span class="keywordtype">int</span> QuotesPrevDate = <span class="keywordtype">int</span>.Parse(QuotesPrevQuotes[2]);
<a name="l00301"></a>00301              <span class="keywordtype">int</span> QuotesPrevTime = <span class="keywordtype">int</span>.Parse(QuotesPrevQuotes[3]);
<a name="l00302"></a>00302              <span class="keywordtype">double</span> QuotesPrevHigh = <span class="keywordtype">double</span>.Parse(QuotesPrevQuotes[5].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00303"></a>00303              <span class="keywordtype">double</span> QuotesPrevLow = <span class="keywordtype">double</span>.Parse(QuotesPrevQuotes[6].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00304"></a>00304              <span class="keywordtype">double</span> QuotesPrevClose = <span class="keywordtype">double</span>.Parse(QuotesPrevQuotes[7].Replace(<span class="charliteral">&#39;.&#39;</span>, <span class="charliteral">&#39;,&#39;</span>));
<a name="l00305"></a>00305 
<a name="l00306"></a>00306              <span class="keywordflow">if</span> (((QuotesDate == HistDate) &amp;&amp; (QuotesTime == HistTime)) &amp;&amp; ((QuotesClose != HistClose) || (QuotesHigh != HistHigh) || (QuotesLow != HistLow)))
<a name="l00307"></a>00307              {
<a name="l00308"></a>00308                  <span class="comment">//update the current quote</span>
<a name="l00309"></a>00309              }
<a name="l00310"></a>00310 
<a name="l00311"></a>00311              <span class="keywordflow">if</span> (((QuotesPrevDate == HistDate) &amp;&amp; (QuotesPrevTime == HistTime)) &amp;&amp; ((QuotesPrevClose != HistClose) || (QuotesPrevHigh != HistHigh) || (QuotesPrevLow != HistLow)))
<a name="l00312"></a>00312              {
<a name="l00313"></a>00313                  <span class="comment">//there are new bar, update the previous and append the new bar</span>
<a name="l00314"></a>00314              }
<a name="l00315"></a>00315 
<a name="l00316"></a>00316 
<a name="l00317"></a>00317 
<a name="l00318"></a>00318          }
<a name="l00319"></a>00319          
<a name="l00320"></a>00320          <span class="comment">//enable/disable quotes update</span>
<a name="l00321"></a>00321          <span class="keyword">private</span> <span class="keywordtype">void</span> checkBox1_CheckedChanged(<span class="keywordtype">object</span> sender, EventArgs e)
<a name="l00322"></a>00322          {
<a name="l00323"></a>00323              <span class="keywordflow">if</span> (checkBox1.Checked)
<a name="l00324"></a>00324              {
<a name="l00325"></a>00325                  <a class="code" href="class_skilful_1_1_quik_control.html#ab201bb9ed667b146997836f3d2ae264b">LoadQuotesFilesList</a>(LoadQuotesDir);
<a name="l00326"></a>00326                  <a class="code" href="class_skilful_1_1_quik_control.html#a65adf2ecaa76d942376432e8b3aa25b7">LoadHistoryFilesList</a>(LoadHistoryDir);
<a name="l00327"></a>00327                  fileSystemWatcher1.Path = LoadQuotesDir;
<a name="l00328"></a>00328                  fileSystemWatcher1.NotifyFilter = NotifyFilters.LastWrite;
<a name="l00329"></a>00329                  fileSystemWatcher1.Filter = <span class="stringliteral">&quot;*.txt&quot;</span>;
<a name="l00330"></a>00330                  fileSystemWatcher1.EnableRaisingEvents = <span class="keyword">true</span>;
<a name="l00331"></a>00331              }
<a name="l00332"></a>00332              <span class="keywordflow">else</span>
<a name="l00333"></a>00333              {
<a name="l00334"></a>00334                      listBox1.Items.Clear();
<a name="l00335"></a>00335                      listBox2.Items.Clear();
<a name="l00336"></a>00336                      listBox3.Items.Clear();
<a name="l00337"></a>00337                      fileSystemWatcher1.EnableRaisingEvents = <span class="keyword">false</span>;
<a name="l00338"></a>00338              
<a name="l00339"></a>00339              }
<a name="l00340"></a>00340          }
<a name="l00341"></a>00341 
<a name="l00342"></a>00342      
<a name="l00343"></a>00343 
<a name="l00344"></a>00344 
<a name="l00345"></a>00345     }
<a name="l00346"></a>00346 }
</pre></div></div>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>Указатель</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Классы</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Пространства имен</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Файлы</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Функции</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Переменные</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Перечисления</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Свойства</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>События</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Создано системой&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
